#include <cstdio>
#include <cmath>

long long sum = 0;
int total = 0;

int isPrimer(long long d)
{
	if ( d == 1 ) {
		return 0;
	}
	
	int ret = 1;
	for ( long long i = 2; i <= sqrt(d); i++ ) {
		if ( d % i== 0 ) {
			ret = 0;
			break;
		} 
	}
	return ret;
}

void getComb(int a[], int offset, int n, int k)
{
	if ( k == 0 ) {
		if ( isPrimer(sum) ) {
			total ++;
		}
		return;
	}
	for ( int i = offset; i <= n - k; i++ ) 
	{
		sum += a[i];
		getComb(a, i+1, n, k-1);
		sum -= a[i];
	}
}

int main()
{
	int n = 0, k = 0;
	int a[20] = {0};
	scanf("%d %d", &n, &k);
	for ( int i = 0; i < n; i++ ) {
		scanf("%d", &a[i]);
	}
	getComb(a, 0, n, k);
	printf("%d", total);
	return 0;
}

